package com.sunchen.asc.service.item.repository;

import com.sunchen.asc.service.item.domain.Charge;
import com.sunchen.asc.service.item.vo.ChargeVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ChargeRepository extends JpaRepository<Charge,Long> {

    @Modifying
    @Query("delete from Charge t where t.itemId = ?1")
    void deleteAllByItemId(Long itemId);

    @Query("select new com.sunchen.asc.service.item.vo.ChargeVo(t.id,t.itemId,t.name,t.standard,t.orgName,t.basis,t.remark,t.reductionFlag,t.reductionPrice,t.reductionReason,t.reduceFeeSituation,t.attachName,t.attachId) from Charge t where t.itemId = ?1")
    List<ChargeVo> getVosByItemId(Long itemId);
}
